package com.coolw.test.callback.async;

/**
 * 异步任务
 *
 * @author coolw
 * @date 2025/1/21 19:47
 */
public class AsyncTask {

    private TaskCallback callback;

    public AsyncTask(TaskCallback callback) {
        this.callback = callback;
    }

    public void execute() {
        System.out.println("任务开始执行......");
        try {
            // 模拟任务执行
            Thread.sleep(2000L);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        // 任务执行完成回调
        callback.onComplete("任务执行成功");
    }
}
